﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using LibHuman;

namespace Human
{
	public class frmbc_boiduonghienvat : System.Windows.Forms.Form
	{
		private AccessData mDB=new AccessData();
        DataSet d11 = new DataSet(); 
        DataSet ds_bp = new DataSet();
        Language lan = new Language();
		private frmReport rpt;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txtnam;
		private System.Windows.Forms.Button buttonbcao;
        private System.Windows.Forms.Button buttonkethuc;	
		private string thang,nam,tn,user_dn="";
		private System.Windows.Forms.TextBox txtthang;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.ToolTip toolTip1;
        private System.Windows.Forms.ComboBox combodvi;
        private ComboBox cboLoainv;
        private Label label3;
        private GroupBox groupBox1;
        private GroupBox groupKx;
        private RadioButton rd_tonghop;
        private RadioButton rd_chitiet;
		private System.ComponentModel.IContainer components;

		public frmbc_boiduonghienvat(string s_userdn)
		{			
			InitializeComponent();
            lan.Read_Language_to_Xml(this.Name.ToString(), this);
            lan.Changelanguage_to_English(this.Name.ToString(), this);
            user_dn = s_userdn;
		}
		
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmbc_boiduonghienvat));
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.txtnam = new System.Windows.Forms.TextBox();
            this.buttonkethuc = new System.Windows.Forms.Button();
            this.buttonbcao = new System.Windows.Forms.Button();
            this.txtthang = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.combodvi = new System.Windows.Forms.ComboBox();
            this.cboLoainv = new System.Windows.Forms.ComboBox();
            this.label3 = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.groupKx = new System.Windows.Forms.GroupBox();
            this.rd_tonghop = new System.Windows.Forms.RadioButton();
            this.rd_chitiet = new System.Windows.Forms.RadioButton();
            this.groupBox1.SuspendLayout();
            this.groupKx.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.Navy;
            this.label1.Location = new System.Drawing.Point(39, 13);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(54, 20);
            this.label1.TabIndex = 26;
            this.label1.Text = "Tháng :";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.Navy;
            this.label2.Location = new System.Drawing.Point(39, 37);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(56, 20);
            this.label2.TabIndex = 27;
            this.label2.Text = "Đơn vị :";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtnam
            // 
            this.txtnam.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtnam.ForeColor = System.Drawing.Color.Navy;
            this.txtnam.Location = new System.Drawing.Point(196, 13);
            this.txtnam.MaxLength = 4;
            this.txtnam.Name = "txtnam";
            this.txtnam.Size = new System.Drawing.Size(56, 22);
            this.txtnam.TabIndex = 1;
            this.txtnam.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtnam.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtnam_KeyDown);
            this.txtnam.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtthang_KeyPress);
            // 
            // buttonkethuc
            // 
            this.buttonkethuc.BackColor = System.Drawing.SystemColors.Control;
            this.buttonkethuc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.buttonkethuc.ForeColor = System.Drawing.Color.Navy;
            this.buttonkethuc.Image = global::Human.Properties.Resources.close_r;
            this.buttonkethuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.buttonkethuc.Location = new System.Drawing.Point(146, 129);
            this.buttonkethuc.Name = "buttonkethuc";
            this.buttonkethuc.Size = new System.Drawing.Size(78, 28);
            this.buttonkethuc.TabIndex = 7;
            this.buttonkethuc.Text = "    &Thoát";
            this.toolTip1.SetToolTip(this.buttonkethuc, "Kết thúc");
            this.buttonkethuc.UseVisualStyleBackColor = true;
            this.buttonkethuc.Click += new System.EventHandler(this.buttonkethuc_Click_1);
            // 
            // buttonbcao
            // 
            this.buttonbcao.BackColor = System.Drawing.SystemColors.Control;
            this.buttonbcao.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.buttonbcao.ForeColor = System.Drawing.Color.Navy;
            this.buttonbcao.Image = global::Human.Properties.Resources.ok1;
            this.buttonbcao.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.buttonbcao.Location = new System.Drawing.Point(64, 129);
            this.buttonbcao.Name = "buttonbcao";
            this.buttonbcao.Size = new System.Drawing.Size(78, 28);
            this.buttonbcao.TabIndex = 5;
            this.buttonbcao.Text = "   &Báo cáo";
            this.toolTip1.SetToolTip(this.buttonbcao, "Báo cáo");
            this.buttonbcao.UseVisualStyleBackColor = true;
            this.buttonbcao.Click += new System.EventHandler(this.xem_Click);
            // 
            // txtthang
            // 
            this.txtthang.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtthang.ForeColor = System.Drawing.Color.Navy;
            this.txtthang.Location = new System.Drawing.Point(95, 13);
            this.txtthang.MaxLength = 2;
            this.txtthang.Name = "txtthang";
            this.txtthang.Size = new System.Drawing.Size(46, 22);
            this.txtthang.TabIndex = 0;
            this.txtthang.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtthang.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtthang_KeyDown);
            this.txtthang.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtthang_KeyPress);
            // 
            // label5
            // 
            this.label5.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.ForeColor = System.Drawing.Color.Navy;
            this.label5.Location = new System.Drawing.Point(153, 15);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(43, 18);
            this.label5.TabIndex = 37;
            this.label5.Text = " Năm :";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // combodvi
            // 
            this.combodvi.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.combodvi.ForeColor = System.Drawing.Color.Navy;
            this.combodvi.ItemHeight = 14;
            this.combodvi.Location = new System.Drawing.Point(95, 38);
            this.combodvi.Name = "combodvi";
            this.combodvi.Size = new System.Drawing.Size(158, 22);
            this.combodvi.TabIndex = 2;
            this.combodvi.KeyDown += new System.Windows.Forms.KeyEventHandler(this.combodvi_KeyDown);
            // 
            // cboLoainv
            // 
            this.cboLoainv.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cboLoainv.ForeColor = System.Drawing.Color.Navy;
            this.cboLoainv.ItemHeight = 14;
            this.cboLoainv.Location = new System.Drawing.Point(95, 62);
            this.cboLoainv.Name = "cboLoainv";
            this.cboLoainv.Size = new System.Drawing.Size(158, 22);
            this.cboLoainv.TabIndex = 42;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.Navy;
            this.label3.Location = new System.Drawing.Point(15, 66);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(80, 13);
            this.label3.TabIndex = 43;
            this.label3.Text = "Loại nhân viên:";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.groupKx);
            this.groupBox1.Controls.Add(this.buttonkethuc);
            this.groupBox1.Controls.Add(this.buttonbcao);
            this.groupBox1.Location = new System.Drawing.Point(10, 2);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(272, 162);
            this.groupBox1.TabIndex = 44;
            this.groupBox1.TabStop = false;
            // 
            // groupKx
            // 
            this.groupKx.Controls.Add(this.rd_tonghop);
            this.groupKx.Controls.Add(this.rd_chitiet);
            this.groupKx.Location = new System.Drawing.Point(48, 88);
            this.groupKx.Name = "groupKx";
            this.groupKx.Size = new System.Drawing.Size(191, 35);
            this.groupKx.TabIndex = 44;
            this.groupKx.TabStop = false;
            this.groupKx.Tag = "0";
            // 
            // rd_tonghop
            // 
            this.rd_tonghop.AutoSize = true;
            this.rd_tonghop.Location = new System.Drawing.Point(111, 12);
            this.rd_tonghop.Name = "rd_tonghop";
            this.rd_tonghop.Size = new System.Drawing.Size(70, 17);
            this.rd_tonghop.TabIndex = 1;
            this.rd_tonghop.Text = "Tổng hợp";
            this.rd_tonghop.UseVisualStyleBackColor = true;
            // 
            // rd_chitiet
            // 
            this.rd_chitiet.AutoSize = true;
            this.rd_chitiet.Checked = true;
            this.rd_chitiet.Location = new System.Drawing.Point(17, 12);
            this.rd_chitiet.Name = "rd_chitiet";
            this.rd_chitiet.Size = new System.Drawing.Size(59, 17);
            this.rd_chitiet.TabIndex = 0;
            this.rd_chitiet.TabStop = true;
            this.rd_chitiet.Text = "Chi tiết";
            this.rd_chitiet.UseVisualStyleBackColor = true;
            // 
            // frmbc_boiduonghienvat
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.ClientSize = new System.Drawing.Size(294, 169);
            this.Controls.Add(this.cboLoainv);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.txtthang);
            this.Controls.Add(this.txtnam);
            this.Controls.Add(this.combodvi);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.groupBox1);
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frmbc_boiduonghienvat";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Bồi dưỡng hiện vật";
            this.Load += new System.EventHandler(this.frmbcttluong_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupKx.ResumeLayout(false);
            this.groupKx.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void buttonkethuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		
		private void frmbcttluong_Load(object sender, System.EventArgs e)
		{
			txtthang.Text=DateTime.Now.Month.ToString().PadLeft(2,'0');
			txtnam.Text=DateTime.Now.Year.ToString();	
			thang=txtthang.Text.Trim().PadLeft(2,'0');
			nam=txtnam.Text;
			tn=thang+nam.Substring(2,2);
			Load_bophan();	
			combodvi.SelectedIndex=-1;           
            cboLoainv.DataSource = mDB.get_nhombc().Tables[0];
            cboLoainv.DisplayMember = "tennhom";
            cboLoainv.ValueMember = "manhom";           
            cboLoainv.SelectedIndex = -1;
  		}
		
		private void Load_bophan()
		{
			combodvi.DataSource=mDB.get_bophan().Tables[0];
			combodvi.DisplayMember="tenbp";
			combodvi.ValueMember="madv";			
		}
		private void print()
		{					
			try	{
				string sql,_loaihd="BC & HD";		
				sql=" select '' as bangchu,  '"+thang+"' as thangluong,'"+nam+"' as namluong , to_char(now(),'dd') as n_ngay,to_char(now(),'mm') as n_thang";
				sql+="  , to_char(now(),'yyyy') as n_nam,l.ho||' '||l.ten as hoten,thcc.madv,bp.tenbp";
                sql+= " ,hs.hs1,hs.hs2,hs.hs3,hs.hs4,cv.diengiai,hs_nv.h_hsbdhv hsbdhv";
                sql+= " ,thcc.sn_cong as ngay_bdhv";
                sql += " from " + mDB.user + ".llnv l  inner join " + mDB.user + ".hopdong hd on hd.manv=l.manv";
                sql += " inner join " + mDB.user + ".dmcv cv on cv.macv = hd.macv";
                sql += " inner join " + mDB.user + ".th_chamcong_"+tn+" thcc on l.manv = thcc.manv";
                sql += " inner join " + mDB.user + ".bophan bp on hd.madv = bp.madv ";
                sql += " inner join " + mDB.user + ".heso hs on hs.mmyy=thcc.mmyy";
                sql += " left join " + mDB.user + ".heso_nv_"+tn+" hs_nv on l.manv=hs_nv.manv";
                sql += " inner join "+mDB.user +".mahd mh on hd.loaihd=mh.mahd";
                sql += " inner join " + mDB.user + ".max_lan ml on hd.manv=ml.manv";
                sql += " where hd.lan=ml.lan and hs_nv.h_hsbdhv <> '0' and hs.mmyy='"+tn+"' and thcc.mmyy='"+ tn +"'";
                if (combodvi.SelectedIndex != -1)
                    sql += " and bp.madv='" + combodvi.SelectedValue.ToString() + "'";
                if (cboLoainv.SelectedIndex != -1)
                {
                    string mloai = cboLoainv.SelectedValue.ToString();
                    sql += " and mh.nhombc in (" + mloai+ ")";
                    _loaihd = cboLoainv.Text.ToUpper();
                }
                sql +="  order by hd.mangach desc,l.ten desc";                
                				
				d11=mDB.get_data(sql);
                ds_bp= getdata();
                d11.WriteXml("..\\xml\\h_pc_boiduonghienvat.xml", XmlWriteMode.WriteSchema);
                ds_bp.WriteXml("..\\xml\\h_pc_boiduonghienvat_th.xml",XmlWriteMode.WriteSchema);
				if (d11.Tables[0].Rows.Count > 0)
				{			
				    if(rd_chitiet.Checked)
					{
                        rpt = new frmReport(mDB, d11,lan.Change_language_MessageText("BẢNG KÊ THANH TOÁN BỒI DƯỠNG HIỆN VẬT THÁNG ") +" "+ thang +" "+ lan.Change_language_MessageText(" NĂM ") + " "+nam + " ", "h_pc_boiduonghienvat.rpt", false, user_dn);
						rpt.ShowDialog(this);
					}
                   
				}
                if (ds_bp.Tables[0].Rows.Count > 0)
                { 
                    if (rd_tonghop.Checked)
                    {
                        rpt = new frmReport(mDB, ds_bp, lan.Change_language_MessageText("BẢNG KÊ THANH TOÁN BỒI DƯỠNG HIỆN VẬT THÁNG ") +" "+ thang +" "+ lan.Change_language_MessageText(" NĂM ")+" " + nam + " ", "h_pc_boiduonghienvat_th.rpt", false, user_dn);
                        rpt.ShowDialog(this);
                    }	
                } 
                else
                    MessageBox.Show(lan.Change_language_MessageText("Không có số liệu!"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
			}
			catch(Exception ex)
			{	
				MessageBox.Show(ex.ToString());
			}		
		}
        private DataSet getdata()
        {
           
                string sql, _loaihd = "BC & HD", sql1 = "";
                sql = " select '' as bangchu,  '" + thang + "' as thangluong,'" + nam + "' as namluong , to_char(now(),'dd') as n_ngay,to_char(now(),'mm') as n_thang";
                sql += "  , to_char(now(),'yyyy') as n_nam,l.ho||' '||l.ten as hoten,thcc.madv,bp.tenbp";
                sql += " ,hs.hs1,hs.hs2,hs.hs3,hs.hs4,cv.diengiai,hs_nv.h_hsbdhv hsbdhv,0.0 st1,0.0 st2,0.0 st3,0.0 st4";
                sql += " ,thcc.sn_cong as ngay_bdhv";
                sql += " from " + mDB.user + ".llnv l  inner join " + mDB.user + ".hopdong hd on hd.manv=l.manv";
                sql += " inner join " + mDB.user + ".dmcv cv on cv.macv = hd.macv";
                sql += " inner join " + mDB.user + ".th_chamcong_" + tn + " thcc on l.manv = thcc.manv";
                sql += " inner join " + mDB.user + ".bophan bp on hd.madv = bp.madv ";
                sql += " inner join " + mDB.user + ".heso hs on hs.mmyy=thcc.mmyy";
                sql += " left join " + mDB.user + ".heso_nv_" + tn + " hs_nv on l.manv=hs_nv.manv";
                sql += " inner join " + mDB.user + ".mahd mh on hd.loaihd=mh.mahd";
                sql += " inner join " + mDB.user + ".max_lan ml on hd.manv=ml.manv";
                sql += " where hd.lan=ml.lan and hs_nv.h_hsbdhv <> '0' and hs.mmyy='" + tn + "' and thcc.mmyy='" + tn + "'";
                if (combodvi.SelectedIndex != -1)
                    sql += " and bp.madv='" + combodvi.SelectedValue.ToString() + "'";
                if (cboLoainv.SelectedIndex != -1)
                {
                    string mloai = cboLoainv.SelectedValue.ToString();
                    sql += " and mh.nhombc in (" + mloai + ")";
                    _loaihd = cboLoainv.Text.ToUpper();
                }
                sql += "  order by hd.mangach desc,l.ten desc";
                sql1 = " select distinct bp.madv,to_char(now(),'dd') as n_ngay,to_char(now(),'mm') as n_thang,to_char(now(),'yyyy') as n_nam,bp.tenbp,0.0 st1,0.0 st2,0.0 st3,0.0 st4,0.0 ngay_bdhv from " + mDB.user + ".bophan bp inner join " + mDB.user + ".heso_nv_" + tn + " hs_nv on bp.madv=hs_nv.madv";
                sql1 += " inner join "+mDB.user+".th_chamcong_"+tn+" thcc on thcc.mmyy=hs_nv.mmyy";
                sql1 += " inner join " + mDB.user + ".hopdong hd on hd.madv=bp.madv";
                sql1 += " inner join " + mDB.user + ".mahd mh on hd.loaihd=mh.mahd";
                sql1 += " inner join " + mDB.user + ".max_lan ml on hd.manv=ml.manv";
                sql1 += " where hs_nv.h_hsbdhv <> '0' and thcc.sn_cong>0";
                if (combodvi.SelectedIndex != -1)
                    sql1 += " and bp.madv='" + combodvi.SelectedValue.ToString() + "'";
                if (cboLoainv.SelectedIndex != -1)
                {
                    string mloai = cboLoainv.SelectedValue.ToString();
                    sql1 += " and mh.nhombc in (" + mloai + ")";
                    _loaihd = cboLoainv.Text.ToUpper();
                }
                d11 = mDB.get_data(sql);
                ds_bp = mDB.get_data(sql1);
                if (d11.Tables[0].Rows.Count > 0)
                {
                    string hs_bdhv = "";
                    decimal hs1 = 0, hs2 = 0, hs3 = 0, hs4 = 0, sn_cong = 0, st1 = 0, st2 = 0, st3 = 0, st4 = 0,ts_nc=0;
                    foreach (DataRow dr in ds_bp.Tables[0].Rows)
                    {
                        
                        DataRow[] dr1 = d11.Tables[0].Select("madv='" + dr["madv"].ToString() + "'", "madv asc");
                        st1 = 0; st2 = 0; st3 = 0; st4 = 0; ts_nc = 0;
                        sn_cong = 0;
                        foreach (DataRow r in dr1)
                        {
                            
                            hs_bdhv = r["hsbdhv"].ToString();
                            hs1 = r["hs1"].ToString() != "" ? decimal.Parse(r["hs1"].ToString()) : 0;
                            hs2 = r["hs2"].ToString() != "" ? decimal.Parse(r["hs2"].ToString()) : 0;
                            hs3 = r["hs3"].ToString() != "" ? decimal.Parse(r["hs3"].ToString()) : 0;
                            hs4 = r["hs4"].ToString() != "" ? decimal.Parse(r["hs4"].ToString()) : 0;
                            sn_cong = r["ngay_bdhv"].ToString() != "" ? decimal.Parse(r["ngay_bdhv"].ToString()) : 0;
                            if (hs_bdhv == "1")
                            {                                
                                st1+= sn_cong * hs1;
                            }
                            if (hs_bdhv == "2")
                            {
                                st2 += sn_cong * hs2;
                            }
                            if (hs_bdhv == "3")
                            {
                                st3 += sn_cong * hs3;
                            }
                            if (hs_bdhv == "4")
                            {
                                st4 += sn_cong * hs4;
                            }
                           ts_nc += r["ngay_bdhv"].ToString() != "" ? decimal.Parse(r["ngay_bdhv"].ToString()) : 0;
                        }
                        
                        dr["st1"] = st1.ToString();
                        dr["st2"] = st2.ToString();
                        dr["st3"] = st3.ToString();
                        dr["st4"] = st4.ToString();
                        dr["ngay_bdhv"] = ts_nc.ToString();
                    }
                }
                 return ds_bp;
        }						
		private void xem_Click(object sender, System.EventArgs e)
		{
			thang=txtthang.Text.Trim().PadLeft(2,'0');
			nam=txtnam.Text;			
			if(!mDB.kt_thangnam(thang,nam))	 return;
			tn=thang+nam.Substring(2,2);
			if(!mDB.bMmyy(tn) )//|| !mDB.kt_heso(thang,nam)
			{
				MessageBox.Show(lan.Change_language_MessageText("Dữ liệu chưa tạo !"),AccessData.Msg,MessageBoxButtons.OK,MessageBoxIcon.Warning );
				return;
			}
            print();
           
		}
		private void txtnam_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}{F4}");
		}

		private void cboloaihd_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}{F4}");
		}	

		private void combodvi_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}");
		}	

		private void buttonkethuc_Click_1(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void txtthang_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}");
		}
        private void txtthang_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
                e.KeyChar = '\0';
        }			
	}
}
